package com.jof.framework.hmc.converter;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;

public class StringMessageConverter implements MessageConverter {

	
	public Object fromMessage(Message message) throws JMSException, MessageConversionException {
		TextMessage textMessage = (TextMessage) message;
		String messageStr = textMessage.getText();
		return messageStr;
	}

	
	public Message toMessage(Object obj, Session session) throws JMSException, MessageConversionException {
		TextMessage textMessage = session.createTextMessage();
		String objStr = (String) obj;
		textMessage.setText(objStr);
		return textMessage;
	}

}
